import java.util.Random;
import java.util.Scanner;


public class note2 {
//1.计算水仙花数的方法二
/*public static void main(String[] args) {
    int i=100;

    for(i=100;i<=999;i++){
        int sum=0;
        int x=i;
        while(x!=0){
           sum+=Math.pow(x%10,3);//pow(a,b)——计算a的b次方
           x/=10;
        }
        if(sum==i){
            System.out.println(sum);
        }
    }
}*/



//2.输出输入

/*
public static void main(String[] args) {
    Scanner scan=new Scanner(System.in);

    System.out.println("请输入你的年龄：");
    int age=scan.nextInt();
    System.out.println(age);
    scan.nextLine();
    System.out.println("请输入你的姓名：");
    String name=scan.nextLine();
    System.out.println(name);


*/





        //3.猜数字游戏
        public static void main(String[] args) {
                Random random = new Random();
                Scanner scan = new Scanner(System.in);
                int num = random.nextInt(100);//[0,100),100为开区间
                //System.out.println(num);
                int ret=3;//限制答题次数
                while (ret != 0) {

                        System.out.println("请输入猜测的数据：");

                        int guess = scan.nextInt();
                        if (guess > num) {
                                System.out.println("大了");
                                ret--;
                        } else if (guess < num) {
                                System.out.println("小了");
                                ret--;
                        } else{
                                System.out.println("恭喜，猜对了");
                                ret--;
                        }
                        System.out.println("你还有 "+ret+" 次机会 ");

                }
                if(ret==0){
                        System.out.println("机会用完了，游戏结束");
                }
                scan.close();
        }

}
